package com.studyweb.service.impl;

import com.studyweb.mapper.PoliticsAccumulationMapper;
import com.studyweb.pojo.entity.PoliticsAccumulation;
import com.studyweb.service.PoliticsAccumulationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class PoliticsAccumulationServiceImpl implements PoliticsAccumulationService {
    
    @Autowired
    private PoliticsAccumulationMapper politicsAccumulationMapper;
    
    @Override
    public List<PoliticsAccumulation> list() {
        return politicsAccumulationMapper.list();
    }
    
    @Override
    public PoliticsAccumulation getById(Long id) {
        return politicsAccumulationMapper.getById(id);
    }
    
    @Override
    public void add(PoliticsAccumulation politicsAccumulation) {
        politicsAccumulation.setStatus(0); // 默认状态为正常
        politicsAccumulationMapper.insert(politicsAccumulation);
    }
    
    @Override
    public void update(PoliticsAccumulation politicsAccumulation) {
        politicsAccumulationMapper.update(politicsAccumulation);
    }
    
    @Override
    public void delete(Long id) {
        politicsAccumulationMapper.deleteById(id);
    }
    
    @Override
    public void batchDelete(List<Long> ids) {
        if (ids != null && !ids.isEmpty()) {
            politicsAccumulationMapper.batchDeleteByIds(ids);
        }
    }
    
    @Override
    public List<PoliticsAccumulation> search(String keyword) {
        return politicsAccumulationMapper.listByKeyword(keyword);
    }
}